<?php
/**
 *
 * Show the product details page
 *
 * @package	VirtueMart
 * @subpackage
 * @author Max Milbers, Valerie Isaksen

 * @link http://www.virtuemart.net
 * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * VirtueMart is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * @version $Id: default_images.php 6188 2012-06-29 09:38:30Z Milbo $
 */
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
$numberlimit = 3;
$imgResizeConfig = array(
	'background' => '#ffffff',
	'thumbnail_mode' => 'stretch'
);					
YTTemplateUtils::getImageResizerHelper($imgResizeConfig);

$app = & JFactory::getApplication();
$templateDir = JURI::base() . 'templates/' . $app->getTemplate();
 
// Product Main Image
if (!empty($this->product->images[0])) {
	$imagesrcmain = YTTemplateUtils::resize($this->product->images[0]->file_url, '305', '210', 'stretch'); //echo $srcmain; die();
?>
    <div class="main-image">
		<a id="yt_cloudzoom" href="<?php echo $this->product->images[0]->file_url;?>" class ="cloud-zoom" rel="zoomWidth:200, zoomHeight:200, adjustX: 20, adjustY: -3" >
			<img class="img-large" src="<?php echo $imagesrcmain;?>" title="" alt="" />
		</a>
    </div>
<?php } 
// Product Main Image END ?>

<?php
// Showing The Additional Images
// if(!empty($this->product->images) && count($this->product->images)>1) {
if (!empty($this->product->images) and count ($this->product->images)>1) {   ?>
    <div class="additional-images yt-carousel">
		<div class="jCarouselLite">
			<ul>
				<?php
				// List all Images
				if (count($this->product->images) > 0) {
					foreach ($this->product->images as $key=>$image) { //echo count($this->product->images); die();
						$imagesradditional = YTTemplateUtils::resize($image->file_url, '305', '210', 'stretch'); 
						$imagesbig = YTTemplateUtils::resize($image->file_url, '610', '420', 'stretch'); 
						?>
						<li>
							<a title="" href="<?php echo $imagesbig;?>" rel="useZoom: 'yt_cloudzoom', smallImage: '<?php echo $imagesradditional;?>'" class="cloud-zoom-gallery<?php if ($key==0) echo ' active';?>" >
								<img class="nav_thumb" src="<?php echo $imagesradditional;?>" alt="" />
							</a>
						</li>
						<?php
					}
				}
				?>
			</ul>
        </div>
        <?php if(count($this->product->images) > $numberlimit){?>
			<div class="nav_button">
				<div class="prev">&nbsp;</div>
				<div class="next">&nbsp;</div>
			</div>
		<?php }?>
		<div class="clear"></div>
    </div>
<?php
} // Showing The Additional Images END ?>

<?php
$document = JFactory::getDocument();
$app = JFactory::getApplication();
$templateDir = JURI::base() . 'templates/' . $app->getTemplate();
?>
<script type="text/javascript" src="<?php echo $templateDir.'/js/cloud-zoom.1.0.2.js' ?>">
</script>
<script type="text/javascript" src="<?php echo $templateDir.'/js/carousel_lite.js' ?>">
</script>
<?php
$document->addStyleSheet($templateDir.'/css/cloud-zoom.css');
?>
<script type="text/javascript">
	jQuery(document).ready(function($) {
		<?php if(count($this->product->images) > $numberlimit){ ?>
		$(".yt-carousel .jCarouselLite").jCarouselLite({
			btnPrev: ".yt-carousel .prev",
			btnNext: ".yt-carousel .next",
			visible: <?php echo $numberlimit;?>
		});
		<?php } ?>
		$('a.cloud-zoom-gallery').bind('click', function(){
			$('a.cloud-zoom-gallery').removeClass('active');
			$(this).addClass('active');
		}); 
	});
</script>
<?php
